<!-- xuwencheng  2022年6年29日18:00  这是我的wenzhangbianji -->
<!-- 编辑 -->
<template>
  <el-dialog
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :destory-on-close="true"
    :title="title"
    :visible.sync="dialogFormVisible"
    width="65%"
    @close="close"
  >
    <el-form ref="form" label-width="200px" :model="form" :rules="rules">
      <el-form-item label="剧组姓名" prop="crewName">
        {{ form.crewName }}
      </el-form-item>
      <el-form-item label="剧组类别" prop="crewClass">
        <el-select
          v-model="form.crewClass"
          disabled
          placeholder="请选择剧组类别"
        >
          <el-option
            v-for="item in options1"
            :key="item.id"
            disabled
            :label="item.creClasName"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="剧组题材" prop="crewThemeId">
        <el-select v-model="form.crewThemeId" placeholder="请选择剧组题材">
          <el-option
            v-for="item in options3"
            :key="item.id"
            :label="item.themeName"
            :value="item.id"
            @click.native="choose(item)"
          />
        </el-select>
      </el-form-item> -->
      <el-form-item label="剧组题材" prop="crewTheme">
        {{ form.crewTheme }}
      </el-form-item>
      <el-form-item label="拍摄时间" prop="crewTime">
        {{ form.crewTime }}
      </el-form-item>
      <el-form-item label="故事梗概" prop="storyTheme">
        {{ form.storyTheme }}
      </el-form-item>
      <el-form-item label="导演姓名" prop="director">
        {{ form.director }}
      </el-form-item>
      <!-- <el-form-item label="选择城市" prop="cityId">
        <el-cascader
          v-model="form.cityId"
          disabled
          :options="options"
          style="width: 100%"
          @change="addressChoose"
        />
      </el-form-item> -->
      <el-form-item label="区域" prop="areaId">
        <el-select v-model="form.areaId" disabled placeholder="请选择区域">
          <el-option
            v-for="item in options2"
            :key="item.id"
            disabled
            :label="item.areaName"
            :value="item.id"
            @click.native="chooseone(item)"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="主演名称" prop="protagonist">
        {{ form.protagonist }}
      </el-form-item>
      <el-form-item label="审核状态" prop="checkValue">
        <el-select v-model="form.checkValue" placeholder="请选择审核状态">
          <el-option
            v-for="item in options5"
            :key="item.id"
            :label="item.creClasName"
            :value="item.id"
            @click.native="optosall(item)"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        v-if="form.checkValue == 0"
        label="驳回原因"
        prop="rejectReason"
      >
        <el-input v-model="form.rejectReason" placeholder="请输入驳回原因" />
      </el-form-item>
    </el-form>
    <el-button class="baocun" size="medium" type="primary" @click="save">
      保存
    </el-button>
  </el-dialog>

  <!-- 增加 -->
</template>

<script>
  /* eslint-disable*/
  import {
    doAdd,
    doEdit,
    crewClass,
    areaId,
    crewtheme,
    check,
  } from '@/api/jvzu'
  import {
    provinceAndCityData,
    regionData,
    provinceAndCityDataPlus,
    regionDataPlus,
    CodeToText,
    TextToCode,
  } from 'element-china-area-data'
  //import { number } from 'echarts'
  export default {
    name: 'search',

    data() {
      return {
        options: regionDataPlus,
        selectedOptions: [],
        token: '',
        imageUrl: '',
        value: true,
        value1: true,
        dialogImageUrl: '',
        dialogVisible: false,
        disabled: false,
        options1: [], //审核状态
        options2: [],
        options3: [],
        options5: [
          {
            id: 1,
            creClasName: '审核通过',
          },
          {
            id: 0,
            creClasName: '审核未通过',
          },
        ],
        valueone: '',
        valuetwo: '',
        form: {
          cityId: '', //chengshiid
          sort: 0,
          roles: [],
          displayLocked: true,
          recommendLocked: true,
          share: true,
          locked: false,
          crewThemeId: '', //剧组题材id
          surfacePlot: '',
          crewTheme: '', //剧组题材
          cityName: '', //城市名
          areaName: '', //区域名称
          areaId: '', //区域id
          starUserId: '', //移动端用户id
          beCheckedId: '', //被审核的数据的主键id
          checkValue: '', //审核的结果
          rejectReason: '空', //拒绝原因
        },
        activated() {
          if (this.$refs.MaskVideo.src) this.$refs.MaskVideo.play()
        },
        deactivated() {
          if (this.$refs.MaskVideo.src) this.$refs.MaskVideo.pause()
        },

        rules: {
          rejectReason: [
            { required: true, trigger: 'blur', message: '请输入驳回原因' },
          ],
          checkValue: [
            { required: true, trigger: 'change', message: '请选择审核状态' },
          ],
          crewName: [
            { required: true, trigger: 'blur', message: '请输入剧组姓名' },
          ],
          crewClass: [
            { required: true, trigger: 'change', message: '请选择剧组类别' },
          ],
          crewTheme: [
            { required: true, trigger: 'change', message: '请输入剧组题材' },
          ],
          crewTime: [
            { required: true, trigger: 'blur', message: '请输入拍摄时间' },
          ],
          storyTheme: [
            { required: true, message: '请输入故事梗概', trigger: 'blur' },
          ],
          director: [
            { required: true, trigger: 'blur', message: '请输入导演姓名' },
          ],
          cityId: [
            { required: true, trigger: 'change', message: '请选择城市' },
          ],
          areaId: [
            { required: true, trigger: 'change', message: '请选择区域' },
          ],
          crewAddress: [
            { required: true, trigger: 'blur', message: '请输入剧组定位' },
          ],
        },
        title: '',
        dialogFormVisible: false,
      }
    },
    created() {
      this.fetchData()
      this.fetchDatatwo()
      this.fetchDatathree()
    },
    methods: {
      choose(e) {
        this.form.crewTheme = e.themeName
        this.form.crewThemeId = e.id
      }, //选择区域
      chooseone(e) {
        this.form.areaName = e.areaName
        this.form.areaId = e.id
      },
      handleChange(a) {
        this.form.particulars = a
      },
      handleAvatarSuccess(res, file, fileList) {
        this.imageUrl = URL.createObjectURL(file.raw)
        console.log(res)
        this.form.surfacePlot = res.data
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg'
        const isLt2M = file.size / 1024 / 1024 < 2
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!')
        }
        return true
      },
      showEdit(row) {
        if (!row) {
          this.title = '添加'
        } else {
          this.title = '处理'
          this.form = Object.assign({}, row)
          this.form.starUserId = row.userId
          this.form.beCheckedId = row.id
          console.log(row)
        }
        this.dialogFormVisible = true
      },
      optosall(e) {
        this.form.checkValue = e.id
        console.log(this.form.checkValue)
      },
      close() {
        let userId = this.form.userId
        this.$refs['form'].resetFields()
        this.form = this.$options.data().form
        if (!this.form.id) {
          this.form.userId = userId
        }
        console.log(this.form)
        this.dialogFormVisible = false
        this.imageUrl = ''
        // this.form = ''
      },
      save() {
        const msg = check(this.form)
        msg.then((res) => {
          console.log(res)
          this.$emit('fetch-data')
          this.close()
          msg.then((res) => {
            if (res.msg === '修改成功') {
              this.$baseMessage(res.msg, 'success', 'vab-hey-message-success')
            }
          })
        })
      },
      async fetchData() {
        let queryForm = {}
        const res = await crewClass(queryForm)
        this.options1 = res.data
      },

      async fetchDatatwo() {
        let queryForm = {}
        const res = await areaId(queryForm)
        this.options2 = res.data
      },
      async fetchDatathree() {
        let that = this
        let queryForm = {}
        const res = await crewtheme(queryForm)
        this.options3 = res.data
      },
      nickNameChange() {
        this.$forceUpdate()
      },
      /**省市区三级联动 */
      // addressChoose(value) {
      //   console.log(value)

      //   this.form.cityId = value[2]
      //   this.form.cityName =
      //     CodeToText[value[0]] +
      //     '/' +
      //     CodeToText[value[1]] +
      //     '/' +
      //     CodeToText[value[2]]
      // },
    },
  }
</script>
<style>
  /* .huakuai {
    position: relative;
    left: 96%;
  } */
  .avatar-uploader .el-upload {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409eff;
  }
  .avatar-uploader-icon {
    width: 178px;
    height: 178px;
    font-size: 28px;
    line-height: 178px;
    color: #8c939d;
    text-align: center;
  }
  .avatar {
    display: block;
    width: 178px;
    height: 178px;
  }
  .baocun {
    width: 100%;
    height: 100%;
  }
</style>
